﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ManagWarInfo : Page
    {
        protected Button butDefault;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLShowType;
        protected HtmlInputHidden txtExamMemo;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            string cmdText = "Update SysInfo set ExamEemo=@ExamEemo";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(cmdText, connection);
            command.Parameters.Add("@ExamEemo", SqlDbType.Text).Value = this.txtExamMemo.Value;
            command.ExecuteNonQuery();
            command.Dispose();
            connection.Close();
            connection.Dispose();
            this.publicFun_0.ExecuteSql("update SysParmInfo set ParmValue='" + this.RBLShowType.SelectedItem.Value + "' where ParmMemo='ExamWarnShow';insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('编辑考试注意事项！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
            this.txtExamMemo.Value = this.publicFun_0.GetValues("select ExamEemo from SysInfo", "ExamEemo");
            base.Response.Write("<script>alert('保存考试注意事项操作成功！')</script>");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() == "Yes")
                    {
                        this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagSysSet from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagSysSet");
                        this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                        if (!(this.ViewState["UserPower"].ToString() != "Y"))
                        {
                            this.butDefault.Attributes.Add("onclick", "javascript:{if(confirm('确定提交考试注意事项吗？')==false) return false;}");
                        }
                        else
                        {
                            this.butDefault.Enabled = false;
                            base.Response.Write("<script>alert('系统设置权限未开放！')</script>");
                        }
                        this.txtExamMemo.Value = this.publicFun_0.GetValues("select ExamEemo from SysInfo", "ExamEemo");
                        if (this.txtExamMemo.Value == "")
                        {
                            this.publicFun_0.ExecuteSql("insert into SysInfo(SysName,SysVersion,SysCode,SysStyle,ExamEemo) values('平凡网上考试学习系统V5','V5','0','blue','离开考场时必须单击“交卷”按钮！')");
                            this.txtExamMemo.Value = "离开考场时必须单击“交卷”按钮！";
                        }
                        string str = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='ExamWarnShow'", "ParmValue").Trim();
                        if (str.Trim() == "")
                        {
                            this.RBLShowType.SelectedIndex = -1;
                            this.RBLShowType.Items.FindByValue("Y").Selected = true;
                            this.publicFun_0.ExecuteSql("Insert into SysParmInfo(ParmName,ParmValue,ParmMemo) values('考试注意事项显示','Y','ExamWarnShow')");
                        }
                        else
                        {
                            this.RBLShowType.SelectedIndex = -1;
                            this.RBLShowType.Items.FindByValue(str).Selected = true;
                        }
                    }
                    else
                    {
                        base.Response.Write("<script>alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')</script>");
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

